<?php

namespace App\Http\Controllers;

use Illuminate\Auth\Events\Validated;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;



class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;


    /**
     * 构造方法
     * @access public
     */
    public function __construct()
    {

        // 控制器初始化
        $this->initialize();
    }

    // 初始化
    protected function initialize()
    {

    }



    protected function success($data = [], $msg = 'success')
    {
        return response()->json([
            'code' => 200,
            'msg' => $msg,
            'data' => $data,
            'timestamp' => time(),
            'success' => true,
            'error' => [],
        ]);
    }


    protected function error($msg = 'error', $data = [], $code = 0)
    {
        return response()->json([
            'code' => $code,
            'msg' => $msg,
            'data' => $data,
            'timestamp' => time(),
            'success' => false,
            'error' => [],
        ]);
    }
}

